home *** CD-ROM | disk | FTP | other *** search
- /* date() */
- /* This function performs a system function call to get the system */
- /* date, and returns a formattted string via the pointer `ptr'. */
-
- date(ptr, mode)
- char *ptr;
- int mode;
- #define GET_DATE 0x2A
- #define byte char
- #define ONE 1
- #define TWO 2
- #define THREE 3
- #define FOUR 4
- #define FIVE 5
- #define SIX 6
- #define SEVEN 7
-
- {
-
- int hold_yr;
- struct XREG {short ax, bx, cx, dx, si, di;};
- struct HREG {byte al, ah, bl, bh, cl, ch, dl, dh;};
- union REGS {
- struct XREG x;
- struct HREG h;
- } inregs, outregs;
-
- struct dt {
- short month;
- short day;
- short year;
- char *mname;
- char *lname;
- };
-
- struct dt pdate;
-
- static char *name[] = {
- "invalid",
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
-
- static char *name2[] = {
- "invalid",
- "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December"
- };
-
- inregs.h.ah = GET_DATE;
- inregs.h.al = 0;
- intdos(&inregs, &outregs);
-
- pdate.day = outregs.h.dl;
- pdate.month = outregs.h.dh;
- pdate.year = outregs.x.cx;
- pdate.mname = name[pdate.month];
- pdate.lname = name2[pdate.month];
-
- if (pdate.year >= 2000)
- hold_yr = pdate.year - 2000;
- else hold_yr = pdate.year - 1900;
-
- switch (mode) {
- case ONE:
- sprintf(ptr, "%02d%02d%02d", hold_yr, pdate.month, pdate.day);
- break;
- case TWO:
- sprintf(ptr, "%02d/%02d/%02d", pdate.month, pdate.day, hold_yr);
- break;
- case THREE:
- sprintf(ptr, "%02d-%02d-%02d", pdate.month, pdate.day, hold_yr);
- break;
- case FOUR:
- sprintf(ptr, "%s %02d, %d", pdate.mname, pdate.day, pdate.year);
- break;
- case FIVE:
- sprintf(ptr, "%s %02d, %d", pdate.lname, pdate.day, pdate.year);
- break;
- case SIX:
- sprintf(ptr, "%02d %s %02d", pdate.day, pdate.mname, hold_yr);
- break;
- case SEVEN:
- sprintf(ptr, "%02d %s %02d", pdate.day, pdate.mname, pdate.year);
- break;
- default:
- break;
- }
- }